using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Contracts.Contracts;
using Simple.Contracts.Models;
using Simple.Contracts.Models.Common;
using Simple.WebAi.Authorizes;
using System.ComponentModel.DataAnnotations;

namespace Simple.WebAi.Controllers
{
    /// <summary>
    /// 照护任务控制器
    /// </summary>
    [Route("api/care-mission")]
    [AccountAuthorize]
    [ApiController]
    public class CareMissionController : ControllerBase
    {
        private readonly ICareMissionService _careMissionService;

        /// <summary>
        /// 依赖注入
        /// </summary>
        /// <param name="careMissionService">照护任务服务</param>
        public CareMissionController(ICareMissionService careMissionService)
        {
            _careMissionService = careMissionService;
        }

        /// <summary>
        /// 获取照护任务列表（无需分页）
        /// </summary>
        /// <returns>照护任务列表</returns>
        [HttpGet("list")]
        [AccountAuthorize]
        public async Task<Result<List<CareMissionDto>>> List()
        {
            return await _careMissionService.List();
        }

        /// <summary>
        /// 保存照护任务信息
        /// </summary>
        /// <param name="input">照护任务保存参数</param>
        /// <returns>保存结果</returns>
        [HttpPost("save")]
        [AccountAuthorize]
        public async Task<Result<long>> Save(CareMissionSaveInput input)
        {
            return await _careMissionService.Save(input);
        }

        /// <summary>
        /// 删除照护任务
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost("delete")]
        [AccountAuthorize]
        public async Task<Result<bool>> Delete([FromQuery][Required] long id)
        {
            return await _careMissionService.Delete(id);
        }
    }
}